# cmake最低版本
# Set the minimum required version of cmake for a project.
cmake_minimum_required(VERSION 3.0)

# 项目名称
# Set a name, version, and enable languages for the entire project.
project(gb28181 VERSION 0.1.1)

message("=======================================")
message("项目版本信息")
message("---------------------------------------")
message(${PROJECT_NAME})
message(${PROJECT_SOURCE_DIR})
message(${PROJECT_BINARY_DIR})
message(${PROJECT_VERSION})
message("---------------------------------------")

set (CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -g -std=c++11")

# 源代码文件和头文件加入变量SRC_LIST(可多组)
# Find all source files in a directory.
aux_source_directory(src SRC_LIST)
aux_source_directory(src/Utils SRC_LIST)
aux_source_directory(src/Global SRC_LIST)
aux_source_directory(src/GBMgr SRC_LIST)
aux_source_directory(src/DBMgr SRC_LIST)
aux_source_directory(src/GBMgr/EventMgr SRC_LIST)
aux_source_directory(src/GBMgr/TaskMgr SRC_LIST)
aux_source_directory(src/GBMgr/SDPHandler SRC_LIST)

message(STATUS "=======================================")
message(STATUS "项目源文件列表")
message(STATUS "---------------------------------------")
foreach(src_filename ${SRC_LIST})
    message(STATUS ${src_filename})
endforeach(src_filename)
message(STATUS "---------------------------------------")

# 头文件路径(可多组)
# Add include directories to the build.
include_directories(include)
include_directories(src)
include_directories(src/Utils)
include_directories(src/Global)
include_directories(src/GBMgr)
include_directories(src/DBMgr)
include_directories(src/GBMgr/EventMgr)
include_directories(src/GBMgr/TaskMgr)
include_directories(src/GBMgr/SDPHandler)

# 库搜索路径(可多组)
# Specify directories in which the linker will look for libraries.
link_directories(/home/gj027/Test/C++/jrtplib/JRTPLIB/install/lib)
link_directories(/home/gj027/Test/C++/jrtplib/JThread/install/lib)
link_directories(/home/gj027/Test/C++/jrtplib/libs/libosip/lib)
link_directories(/home/gj027/Test/C++/jrtplib/libs/libexosip/lib)

# 生成程序名
# Add an executable to the project using the specified source files.
ADD_EXECUTABLE(gb28181 ${SRC_LIST})

# 库名(可多组)
# Link a target to given libraries
target_link_libraries(gb28181 -ljrtp)
target_link_libraries(gb28181 -ljthread -lpthread)
target_link_libraries(gb28181 -losipparser2 -losip2 -leXosip2)

# 设置安装路径
set(CMAKE_INSTALL_BINDIR "bin")
message(STATUS "=======================================")
message(STATUS "CMAKE_INSTALL_BINDIR")
message(STATUS "---------------------------------------")
message(STATUS ${CMAKE_INSTALL_BINDIR})
message(STATUS "---------------------------------------")

# 安装配置
install(
    TARGETS gb28181
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 
)